package com.vvv.shortlink.admin.remote;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vvv.shortlink.common.convention.result.Result;
import com.vvv.shortlink.admin.remote.dto.req.*;
import com.vvv.shortlink.admin.remote.dto.resp.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@FeignClient(value = "short-link-project", url = "${aggregation.remote-url:}")
public interface ShortLinkProjectClient {

    /**
     * 分页查询短链接
     */
    @GetMapping("/api/short-link/v1/page")
    Result<Page<LinkPageRespDTO>> pageShortLink(@SpringQueryMap LinkPageReqDTO requestParam);

    /**
     * 创建短链接
     */
    @PostMapping("/api/short-link/v1/create")
    Result<LinkCreateRespDTO> createShortLink(@RequestBody LinkCreateReqDTO requestParam);

    /**
     * 列出短链接组计数
     */
    @GetMapping("/api/short-link/v1/count")
    Result<List<LinkGroupCountRespDTO>> listShortLinkGroupCount(@RequestParam("userId") Long userId);

    /**
     * 更新短链接
     */
    @PostMapping("/api/short-link/v1/update")
    Result<Void> updateShortLink(@RequestBody LinkUpdateReqDTO requestParam);

    /**
     * 获取原始URL的标题
     */
    @GetMapping("/api/short-link/v1/title")
    Result<String> getTitleByUrl(@RequestParam("url") String url);

    /**
     * 将短链接保存到回收站
     */
    @PostMapping("/api/short-link/v1/recycle-bin/save")
    Result<Void> saveLinkToBin(@RequestBody RecycleBinSaveReqDTO requestParam);

    /**
     * 分页查询回收站中的短链接
     */
    @GetMapping("/api/short-link/v1/recycle-bin/page")
    Result<Page<LinkPageRespDTO>> pageShortLinkInBin(@SpringQueryMap RecycleBinPageReqDTO requestParam);

    /**
     * 从回收站中恢复短链接
     */
    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    Result<Void> recoverShortLinkFromBin(@RequestBody RecycleBinRecoverReqDTO requestParam);

    /**
     * 从回收站中移除短链接
     */
    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    Result<Void> removeShortLinkFromBin(@RequestBody RecycleBinRemoveReqDTO requestParam);

    /**
     * 访问单个短链接指定时间内的监控数据
     */
    @GetMapping("/api/short-link/v1/stats")
    Result<LinkStatsRespDTO> shortLinkStats(@SpringQueryMap LinkStatsReqDTO requestParam);

    /**
     * 分页查询单个短链接的监控访问记录
     */
    @GetMapping("/api/short-link/v1/stats/access-record")
    Result<Page<LinkStatsAccessRecordRespDTO>> shortLinkStatsAccessRecord(@SpringQueryMap LinkStatsAccessRecordReqDTO requestParam);

    /**
     * 批量创建短链接
     */
    @PostMapping("/api/short-link/v1/create/batch")
    Result<LinkBatchCreateRespDTO> batchCreateShortLink(@RequestBody LinkBatchCreateReqDTO requestParam);
}
